﻿namespace WMS6.Web.Administration
{
    using System;
    using System.Configuration;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class GlobalSetting : BasePage
    {
        protected Button btnSave;
        protected HtmlForm F1085;
        protected Label lblAnalyticsReportListPageCount;
        protected Label lblButton;
        protected Label lblGlobalSetting;
        protected Label lblLoginImageUrl;
        protected Label lblLoginTitle;
        protected Label lblMsg;
        protected Label lblOrderSelectionAdvanceStartDate;
        protected Label lblPageDetailCount;
        protected Label lblPassword;
        protected Label lblPortalTitle;
        protected Label lblPrintReportLogo;
        protected Label lblPrintReportTitle;
        protected Label lblPriorityFlag;
        protected Label lblSearchKey;
        protected Label lblSystemLogo;
        protected Label lblUserName;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtButton;
        protected TextBox txtLoginImageUrl;
        protected TextBox txtLoginTitle;
        protected TextBox txtnalyticsReportListPageCount;
        protected TextBox txtOrderSelectionAdvanceStartDate;
        protected TextBox txtPageDetailCount;
        protected TextBox txtPassword;
        protected TextBox txtPortalTitle;
        protected TextBox txtPrintReportLogo;
        protected TextBox txtPrintReprotTitle;
        protected TextBox txtPriorityFlag;
        protected TextBox txtSearchKey;
        protected TextBox txtSystemLogo;
        protected TextBox txtUserName;
        protected UpdatePanel up1;

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ConfigurationManager.AppSettings.Set("PAGE_LOGIN_TITLE", this.txtLoginTitle.Text);
                ConfigurationManager.AppSettings.Set("PAGE_PORTAL_TITLE", this.txtPortalTitle.Text);
                ConfigurationManager.AppSettings.Set("LOGIN_IMAGE_URL", this.txtLoginImageUrl.Text);
                ConfigurationManager.AppSettings.Set("LOGIN_USER_NAME", this.txtUserName.Text);
                ConfigurationManager.AppSettings.Set("LOGIN_PASSWORD", this.txtPassword.Text);
                ConfigurationManager.AppSettings.Set("LOGIN_BUTTON", this.txtButton.Text);
                ConfigurationManager.AppSettings.Set("PRINT_REPORT_TITLE", this.txtPrintReprotTitle.Text);
                ConfigurationManager.AppSettings.Set("PRINT_REPORT_LOGO", this.txtPrintReportLogo.Text);
                ConfigurationManager.AppSettings.Set("PAGE_TITLE_LOGO", this.txtSystemLogo.Text);
                ConfigurationManager.AppSettings.Set("PAGE_DETAIL_COUNT", this.txtPageDetailCount.Text);
                ConfigurationManager.AppSettings.Set("ANALYTICS_REPORT_LIST_PAGE_COUNT", this.txtnalyticsReportListPageCount.Text);
                ConfigurationManager.AppSettings.Set("SEARCH_KEY", this.txtSearchKey.Text);
                ConfigurationManager.AppSettings.Set("ORDER_SELECTION_ADVANCE_STARTDATE", this.txtOrderSelectionAdvanceStartDate.Text);
                ConfigurationManager.AppSettings.Set("PriorityFlag", this.txtPriorityFlag.Text);
                this.lblMsg.Text = "更新成功!";
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = "操作异常：" + ex.Message;
            }
        }

        protected void CacheRemove(object sender, EventArgs e)
        {
            base.Cache.Remove("FUNCTION_ROLE");
            this.Session.Remove("RoleFunctionData");
            base.Cache.Remove("StringOper_CN");
            base.Cache.Remove("StringOper_EN");
            base.Cache.Remove("StringOper_TW");
            base.Cache.Remove("DateTimeOper_CN");
            base.Cache.Remove("DateTimeOper_EN");
            base.Cache.Remove("DateTimeOper_TW");
            base.Cache.Remove("EqualDLLByDT");
            this.lblMsg.Text = "缓存释放成功!";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.WebConfigLoad();
            }
        }

        private void WebConfigLoad()
        {
            try
            {
                this.txtLoginTitle.Text = base.GetValueFromAppSettings("PAGE_LOGIN_TITLE");
                this.txtPortalTitle.Text = base.GetValueFromAppSettings("PAGE_PORTAL_TITLE");
                this.txtLoginImageUrl.Text = base.GetValueFromAppSettings("LOGIN_IMAGE_URL");
                this.txtUserName.Text = base.GetValueFromAppSettings("LOGIN_USER_NAME");
                this.txtPassword.Text = base.GetValueFromAppSettings("LOGIN_PASSWORD");
                this.txtButton.Text = base.GetValueFromAppSettings("LOGIN_BUTTON");
                this.txtPrintReprotTitle.Text = base.GetValueFromAppSettings("PRINT_REPORT_TITLE");
                this.txtPrintReportLogo.Text = base.GetValueFromAppSettings("PRINT_REPORT_LOGO");
                this.txtSystemLogo.Text = base.GetValueFromAppSettings("PAGE_TITLE_LOGO");
                this.txtPageDetailCount.Text = base.GetValueFromAppSettings("PAGE_DETAIL_COUNT");
                this.txtnalyticsReportListPageCount.Text = base.GetValueFromAppSettings("ANALYTICS_REPORT_LIST_PAGE_COUNT");
                this.txtSearchKey.Text = base.GetValueFromAppSettings("SEARCH_KEY");
                this.txtOrderSelectionAdvanceStartDate.Text = base.GetValueFromAppSettings("ORDER_SELECTION_ADVANCE_STARTDATE");
                this.txtPriorityFlag.Text = base.GetValueFromAppSettings("PriorityFlag");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = "操作异常：" + ex.Message;
            }
        }
    }
}

